/**
 * @param {number} n
 * @return {boolean}
 */
 var isHappy = function(n) {
  const happy = (num)=>{
      let sum = 0
      while(num){
          let ge = num % 10
          sum += ge ** 2
          num = Math.floor(num/10)
      }
      return sum
  }
  let hash = {}
  while(true){
      n = happy(n)
      if(n === 1){
          return true
      }
      if(hash[n]){
          return false
      }else{
          hash[n] = true
      }
  }
};